﻿@using HCMessage.Model
@{
    ViewBag.Title = "ItemReportTable";
    var model = (ItemReport)Model;
}
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $(function () {
            $('#myTab li:first').addClass("active");
            $('#divItemList div:first').addClass("active");
        });
        $('#myTab a').click(function (e) {
            var env = $(this).attr("data-env");
            $("#divItemList div").each(function () {
                $(this).removeClass("active");
                if ($(this).attr("data-env") == env) {
                    $(this).addClass("active");
                }
            });
        });
        $("#btn_submit").click(function () {
            $.ajax({
                type: "post",
                url: '/Report/GetItemReportData',
                error: function () { alert('Failed!'); },
                success: function (data, textStatus) {
                    alert("3");
                }
            });
        });
    });
</script>
<h2 class="page-header">
    Item Report
</h2>
<ul class="nav nav-tabs" id="myTab">
    @foreach (var r in model.EnvCtList)
    {
        <li><a href="#" role="tab" data-toggle="tab" data-env="@r.EnvCode">@r.EnvCode</a></li>
    }
</ul>
<div class="tab-content" id="divItemList">
    @foreach (var r in model.EnvCtList)
    {
        var flag = 0;
        var itemList = model.ItemReportList.Where(x => x.EnvCd == r.EnvCode).ToList();
        if (itemList.Count > 0)
        {
        <div class="table-responsive tab-pane" data-env="@r.EnvCode" >
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>
                            Name
                        </th>
                        <th>
                            Address
                        </th>
                        <th>
                            Status
                        </th>
                        <th>
                            Time Stamp
                        </th>
                        <th>
                            Description
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in itemList)
                    {
                        <tr>
                            <td>@item.Name
                            </td>
                            <td>@item.Address
                            </td>
                            <td>
                                @if (item.Status.ToUpper() == "PASS")
                                {
                                   <button type="button" class="btn btn-sm btn-success">PASS</button> 
                                } else
                                {
                                <button type="button" class="btn btn-sm btn-danger">FAIL </button>
                                }
                                
                            </td>
                            <td>Thursday oct 30 19:21:10 UTC 2014</td>
                            <td>
                                <button type="button" class="btn btn-sm btn-primary">
                                    Detail</button>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
        }
    }
</div>
